package netty.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    public final static String CHAT_TOPIC="CHAT-TOPIC";
    public final static String CHAT_EXCHANGE="CHAT-EXCHANGE";
    @Bean
    public Queue chatQueue(){
        return new Queue(CHAT_TOPIC);
    }
    @Bean
    public TopicExchange exchange(){
        return new TopicExchange(CHAT_EXCHANGE);
    }
    @Bean
    public Binding bindChatTopicToChatExchange(){
        return BindingBuilder.bind(chatQueue()).to(exchange()).with(CHAT_TOPIC);
    }
}
